//
//  CalcTableViewCell.m
//  OutesIOS
//
//  Created by norman on 2019/2/24.
//  Copyright © 2019 norman. All rights reserved.
//

#import "CalcTableViewCell.h"

@interface CalcTableViewCell()

@property (nonatomic,strong)UIButton *btnCalc;

@property (nonatomic,strong)UILabel *infoLabel;

@property (nonatomic,strong)UILabel *unitLabel;

@end

@implementation CalcTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupViews];
    }
    return self;
}

- (void)setupViews {
    self.contentView.height = 44;
    self.btnCalc = [UIButton buttonWithStyle:StrapSuccessStyle andTitle:@"计算总负荷" andFrame:CGRectMake(30, 0, kScreen_Width - 60, 30) target:self action:@selector(calcLoad)];
    [self.btnCalc setTitleColor: [UIColor whiteColor] forState:UIControlStateNormal];
    //    [loginBtn setBackgroundColor:CM_ORANGE_COLOR];
    [self.btnCalc setBackgroundImage:[UIImage imageWithColor:CM_ORANGE_COLOR] forState:UIControlStateNormal];
    
    self.btnCalc.titleLabel.font = [UIFont systemFontOfSize:15];
    self.btnCalc.centerY = 22;
    [self.contentView addSubview:self.btnCalc];
    
    //单位
    self.unitLabel = [UILabel labelSingleLineFontSize:kListTitleFontSize content:@"kW"];
    self.unitLabel.textColor = CM_TABLE_TITLE_COLOR;
    self.unitLabel.x = kScreen_Width - CELL_PADDING_RIGHT - self.unitLabel.width;
    self.unitLabel.centerY = 22;
//    [self.contentView addSubview:self.unitLabel];
    
    //信息label
    self.infoLabel = [UILabel labelSingleLineFontSize:14 content:@"信息"];
    self.infoLabel.x = kScreen_Width/2;
    self.infoLabel.width = self.unitLabel.x - 2 - self.infoLabel.x;
    self.infoLabel.textAlignment = NSTextAlignmentRight;
    self.infoLabel.centerY = 22;
    self.infoLabel.textColor = CM_TABLE_DETAIL_COLOR;
//    [self.contentView addSubview:self.infoLabel];
}

- (void)calcLoad {
    if (self.calcClicked) {
        self.calcClicked();
    }
}

- (void)setLoadData:(NSString *)load {
    self.infoLabel.text = load;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
